/*
 * TermsAndConditions.java
 *
 * Created on March 26, 2003, 11:53 AM
 */

package com.scalar.chiptrack.sales;

import com.scalar.chiptrack.utils.StringUtils;

/**
 *
 * @author  KUMAR
 */
public class TermsAndConditions {
    
    private int termsId = -1;
    private String termsTitle = null;
    private String terms = null;
    
    /** Creates a new instance of TermsAndConditions */
    public TermsAndConditions() {
    }
    
    public int getTermsId()
    {
        return termsId;
    }
    public void setTermsId(int termsId)
    {
        this.termsId = termsId;
    }
    
    public String getTermsTitle()
    {
        return termsTitle;
    }
    public void setTermsTitle(String termsTitle)
    {
        this.termsTitle = termsTitle;
    }
    
    public String getTerms()
    {
        return terms;
    }
    public String getXMLFormatTerms(String terms)
    {
        StringBuffer xmlString= new StringBuffer();
        String[] splitTerms = terms.split("<br>" );

        for( int i=0; i<splitTerms.length ; i++)
        {
            xmlString.append("<subDescription> ");
                xmlString.append("<subDescriptionValue> <![CDATA["  + splitTerms[i] + " ]]></subDescriptionValue>") ;
            xmlString.append("</subDescription> ");
        }

        return xmlString.toString();
    }
    public void setTerms(String terms)
    {
        //terms = terms.replaceAll("\'\'", "\'");
        StringBuffer sb=new StringBuffer("");
        String tempStr = "";
        if( terms == null )
        {
            terms = "";
        }
        for(int i=0;i<terms.length();i++)
        {
            char ch = terms.charAt(i);
            //char chNext= terms.charAt(i+1);
            
            if(ch == '\n')
            {
                sb.append("<br>");
            }
            else if(ch == '\t')
            {
                sb.append(" ");
            }
            else
            {
                sb.append(ch);
            }

        }
        tempStr = sb.toString();
        this.terms = tempStr;
    }

}
